import React from 'react'
import { forwardRef, useRef, useImperativeHandle } from 'react'

const Demo = (props, cntRef) => {

  function mySay() {
    console.log("say hello");
  }

  function sayHello(c) {
    console.log(c);
  }

  useImperativeHandle(cntRef, () => ({
    mySay,
    sayHello
  }))

  return (
    <div>
      <h1>首行</h1>
      <div ref={cntRef}>内容1111</div>
    </div>
  )
}

export default forwardRef(Demo)
